﻿using _3_3;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3_3
{
    public class Rect
    {
        protected double length; 
        protected double width;  

       
        public Rect(double length, double width)
        {
            this.length = length;
            this.width = width;
        }

        
        public double GetArea()
        {
            return length * width;
        }

      
        public double GetPerimeter()
        {
            return 2 * (length + width);
        }
    }

    
    public class Cubold : Rect
    {
        private double height; 

      
        public Cubold(double length, double width, double height) : base(length, width)
        {
            this.height = height;
        }

       
        public new double GetArea()
        {
            return 2 * (length * width + length * height + width * height);
        }

       
        public double GetVolume()
        {
            return length * width * height;
        }
    }
}
namespace sy3_3
{
    class Program
    {
        static void Main(string[] args)
        {
          
            Console.Write("请输入矩形长：");
            double length = Convert.ToDouble(Console.ReadLine());

            Console.Write("请输入矩形宽：");
            double width = Convert.ToDouble(Console.ReadLine());

          
            Rect rect = new Rect(length, width);
            Console.WriteLine($"解：矩形面积为 {rect.GetArea()} ，周长为 {rect.GetPerimeter()} 。");

         
            Console.WriteLine("\n=====在此基础上构造矩体=====");
            Console.Write("请输入矩体高：");
            double height = Convert.ToDouble(Console.ReadLine());

         
            Cubold cubold = new Cubold(length, width, height);
            Console.WriteLine($"解：矩体表面积为 {cubold.GetArea()} ，体积为 {cubold.GetVolume()} 。");

            Console.WriteLine("\n按任意键结束程序：");
            Console.ReadKey();
        }
    }
}